package body ReaderTask is

   task body RT is

      Next_Period : Ada.Real_Time.Time;
      Period : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Microseconds(Cycle_Time);
      LocalData : Data;

      package X_IO is new Ada.Text_IO.Integer_IO(Positive);
      use X_IO;

   begin
      -- Initialization code

      Next_Period := Ada.Real_Time.Clock + Ada.Real_Time.Microseconds(Cycle_Time);

      Ada.Text_IO.Put_Line("Activacao da Reader Task ");
      X_IO.Put(Item => Id, Width => 3, Base => 10);
      Ada.Text_IO.Put_Line("");


      loop

         delay until Next_Period; -- wait until next period after offset
                                  -- Non-suspending periodic response code
                                  -- May include calls to protected procedures

         LocalData := PO.Shared_Data.Get;

         Ada.Text_IO.Put("Reader Task ");
         X_IO.Put(Item => Id, Width => 3, Base => 10);
         Ada.Text_IO.Put("  -> Data = ");
         X_IO.Put(Item => Integer (LocalData), Width => 3, Base => 10);
         Ada.Text_IO.Put_Line("");

         Next_Period := Next_Period + Period;

         end loop;
      end RT;
   end ReaderTask;
